/**
  **************************************************************************
  * @file     main.c
  * @brief    main program
  **************************************************************************
  *                       Copyright notice & Disclaimer
  *
  * The software Board Support Package (BSP) that is made available to
  * download from Artery official website is the copyrighted work of Artery.
  * Artery authorizes customers to use, copy, and distribute the BSP
  * software and its related documentation for the purpose of design and
  * development in conjunction with Artery microcontrollers. Use of the
  * software is governed by this copyright notice and the following disclaimer.
  *
  * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  *
  **************************************************************************
  */

#include "at32f423_board.h"
#include "at32f423_clock.h"
#include "tos_k.h"
/** @addtogroup AT32F423_periph_examples
  * @{
  */

/** @addtogroup 423_USART_printf USART_printf
  * @{
  */

__IO uint32_t time_cnt = 0;

k_task_t task;

k_stack_t task_stack[1024];

void test_task(void *Parameter)
{
	while(1)
	{
		printf("hello tobuandOS\r\n");
		tos_task_delay(1000);
	}
}
/**
  * @brief  main function.
  * @param  none
  * @retval none
  */
int main(void)
{
	k_err_t err;
  system_clock_config();
  at32_board_init();
  uart_print_init(115200);

  /* output a message on hyperterminal using printf function */
  printf("usart printf example: retarget the c library printf function to the usart\r\n");
	
	tos_knl_init();
	
	err = tos_task_create(&task,
												"task1",
												test_task,
												NULL,
												2,
												task_stack,
												1024,
												20);
	if(err != K_ERR_NONE)
	{
		printf("TobndOS Create task fail! code:%d \r\n",err);
	}
	tos_knl_start();

}
